package com.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.FandianDAO;
import com.pojo.Fandian;
import com.util.StringUtil;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @Description:
 * @Auther: tz
 * @Date: 2023/12/1 9:51
 */
@Service
public class FandianService extends ServiceImpl<FandianDAO, Fandian> {

    /**
     * 校验参数
     * @param fandian
     * @return
     */
    public String verify(Fandian fandian){
        if (StringUtil.isNull(fandian.getDjName())){
            return "档级名称不能为空";
        }
        if (fandian.getMinMoney().compareTo(BigDecimal.ZERO) < 1){
            return "最小金额需要大于0";
        }
        if (fandian.getMaxMoney().compareTo(BigDecimal.ZERO) < 1){
            return "最大金额需要大于0";
        }
        if (fandian.getMinMoney().compareTo(fandian.getMaxMoney()) == 1){
            return "最大金额不能小于最小金额";
        }
        if (fandian.getFdl().compareTo(BigDecimal.ZERO) < 1){
            return "返点率需要大于等于0";
        }
        return "";
    }
}
